/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package customer;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author jfernan
 */
public class CustomerServiceImpl implements CustomerService  {

    	private CustomerRepository repository;


    public List<CustomerTO> getListOfPendingCustomers() {


        	//List that will be returned
		List<CustomerTO> listCustomerTO = new ArrayList<CustomerTO>();
		//Retrieving values from Repository
		List<Customer> listCustomers = repository.getListOfPendingCustomers();
		//Copying (only required) values to TO
		for (Customer customer : listCustomers) {
			//Only NAME is required for that requirement
			CustomerTO customerTO = new CustomerTO(customer.getName());
			//adding the CustomerTO to list
			listCustomerTO.add(customerTO);
		}
		return listCustomerTO;

                /*

       return null; //  throw new UnsupportedOperationException("Not supported yet.");

                 */
    }


    	/**
	 * Inject the Repository through that method.
	 * We can use Spring, EJB or even Google Guice to do that.
	 *
	 * @param repository
	 */
   public void setRepository(CustomerRepository repository) {
        this.repository = repository;

    }

}
